package com.yanqu.road.server.cmd.activity.hanghai.cross;

import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.entity.task.args.UnionRiseRankArgs;
import com.yanqu.road.pb.activity.HangHaiActivityProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;

import java.math.BigDecimal;
import java.math.BigInteger;

@Cmd(code = GameProtocol.S_HANGHAI_ACTIVITY_NOTIFY_MONEY_CONDITION_FROM_CROSS, desc = "（跨服返回）通知区服更新资金成就")
public class HangHaiNotifyMoneyConditionFromCrossCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        HangHaiActivityProto.CrossHangHaiNotifyMoneyConditionMsg req = HangHaiActivityProto.CrossHangHaiNotifyMoneyConditionMsg.parseFrom(packet.getBytes());
        long totalMoney = req.getTotalMoney();

        player.notifyListener(eGamePlayerEventType.HangHaiUnionMoneyRank.getValue(),
                new UnionRiseRankArgs(UnionRiseRankArgs.NOTIFY_TYPE_NORMAL, BigInteger.valueOf(totalMoney), player.getUserInfo().getUnionUid()));
        player.notifyListener(eGamePlayerEventType.HangHaiMoneyRank.getValue(), totalMoney);
        player.notifyListener(eGamePlayerEventType.HangHaiMoneyTask.getValue(), BigDecimal.valueOf(totalMoney));
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
